<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<h:body>
	<h:form>
		<ui:composition template="/pages/protected/prof/template.xhtml">
			<ui:define name='templatemo_content'>
				<!-- Cabeçalho  -->
				<h2>#{profMB.selectedComp.nome}</h2>
				<p:tabView id="componente" orientation="left" effect="fade">
					<p:tab title="Materiais">
						<!-- Lista -->						</p:tab>
					<p:tab title="Provas">
						<!-- Lista -->
						<h:form id="listaProvas">
							<p:dataTable id="tbProvas" widgetVar="tbProvas" var="prova"
								value="#{profMB.provas}" paginator="true" rows="5"
								paginatorPosition="bottom" resizableColumns="false"
								paginatorTemplate="{PageLinks} {RowsPerPageDropdown}"
								emptyMessage="Nenhuma matrícula foi encontrada para este aluno.">

								<p:column style="width:30%;" headerText="Descrição"
									filterBy="#{prova.descricao}" filterMatchMode="contains">
									<p
										style="width: 150px; overflow-y: auto; word-wrap: break-word; height: 50px;">
										<h:outputText value="#{prova.descricao}" />
									</p>
								</p:column>

								<p:column style="width:300px;" headerText="Temas"
									filterBy="#{prova.temas}" filterMatchMode="contains">
									<p
										style="width: 270px; overflow-y: auto; word-wrap: break-word; height: 50px;">
										<h:outputText value="#{prova.temas}" />
									</p>
								</p:column>

								<!-- Botoes de Acoes -->
								<p:column style="width:10%">
									<p:commandButton id="btnEditar" icon="ui-icon-pencil"
										oncomplete="dlgProva.show()" update=":componente:formProva">
										<f:setPropertyActionListener value="#{prova}"
											target="#{profMB.selectedProva}" />
									</p:commandButton>
									<p:tooltip for="btnEditar" value="Editar" showEffect="fade"
										hideEffect="fade" />

									<p:commandButton id="btnDeletar" icon="ui-icon-trash"
										update=":componente:listaProvas"
										action="#{profMB.doRemoverProva(prova)}">
									</p:commandButton>
									<p:tooltip for="btnDeletar" value="Deletar" showEffect="fade"
										hideEffect="fade" />
								</p:column>
							</p:dataTable>
							<div style="text-align: left;">
								<h:outputText
									value="Total de Provas Agendadas: #{fn:length(profMB.provas)}   " />
								<p:commandButton value="Novo" icon="ui-icon-plus"
									update=":componente:formProva :componente:listaProvas"
									actionListener="#{profMB.doPrepararProva}"
									oncomplete="dlgProva.show()">
								</p:commandButton>
							</div>
						</h:form>

						<p:dialog header="Prova" widgetVar="dlgProva" resizable="false"
							modal="true">
							<h:form id="formProva">

								<p:growl id="messages" showDetail="true" />
								<h:panelGrid columns="2" style="margin-bottom:10px">

									<h:outputLabel value="Aplicável a componente: *" />
									<h:inputText disabled="true"
										value="#{profMB.selectedComp.id} - #{profMB.selectedComp.nome}"
										style="width: 100%;" />

									<h:outputLabel for="pDescricao" value="Descricao:" />
									<p:inputTextarea id="pDescricao" rows="3" cols="54"
										value="#{profMB.selectedProva.descricao}" />

									<h:outputLabel for="pDtAbertura" value="Abertura:" />
									<p:calendar id="pDtAbertura"
										value="#{profMB.selectedProva.dtAbertura}" label="eDia"
										showButtonPanel="true" />


									<h:outputLabel for="pDtEncerramento" value="Encerramento:" />
									<p:calendar id="pDtEncerramento"
										value="#{profMB.selectedProva.dtEncerramento}" label="eDia"
										showButtonPanel="true" />
									<h:outputLabel for="pNivelMin" value="Dificuldade Min: *" />
									<p:spinner id="pNivelMin"
										value="#{profMB.selectedProva.nivelDificuldadeMin}"
										required="true" label="Dificuldade Min" min="1">
									</p:spinner>

									<h:outputLabel for="pNivelMax" value="Dificuldade Max: *" />
									<p:spinner id="pNivelMax"
										value="#{profMB.selectedProva.nivelDificuldadeMax}"
										required="true" label="Dificuldade Max" min="1">
									</p:spinner>

									<h:outputLabel for="pNumQuest" value="Numero Questoes: *" />
									<p:spinner id="pNumQuest"
										value="#{profMB.selectedProva.numQuest}" required="true"
										label="Num. Questoes:" min="1">
									</p:spinner>

									<h:outputLabel for="pTipoQuest" value="Tipo Questaoes: *" />
									<p:selectOneMenu id="pTipoQuest"
										value="#{profMB.selectedProva.tipoQuest}" required="true"
										label="Tipos Questoes">
										<f:selectItems value="#{profMB.tiposQuest}" />
									</p:selectOneMenu>

									<h:outputLabel for="pTemas" value="Temas:" />
									<p:inputTextarea id="pTemas" rows="3" cols="54"
										value="#{profMB.selectedProva.temas}" />
								</h:panelGrid>
								<p:commandButton id="btnSalvar" value="Salvar" ajax="true"
									type="submit" icon="ui-icon-check"
									action="#{profMB.doSalvarProva()}"
									update=":componente:formProva :componente:listaProvas" />
								<p:button value="Cancelar" icon="ui-icon-closethick" ajax="true"
									type="reset"
									update=":componente:formProva :componente:listaProvas"
									process=":@none" oncomplete="dlgProva.hide()" />
							</h:form>
						</p:dialog>
					</p:tab>
				</p:tabView>
			</ui:define>
		</ui:composition>
	</h:form>
</h:body>
</html>